//
//  HD_BLEState.m
//  HDGuiZhouMuseum
//
//  Created by liuyi on 2017/8/28.
//  Copyright © 2017年 liuyi. All rights reserved.
//

#import "HD_BLEState.h"

@implementation HD_BLEState

- (instancetype)init {
    self = [super init];
    if (self) {
        // 蓝牙检测
        self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil];
    }
    return self;
}

#pragma mark - CLLocationManagerDelegate
-(void)centralManagerDidUpdateState:(CBCentralManager *)central {
    //第一次打开或者每次蓝牙状态改变都会调用这个函数
    if(central.state==CBCentralManagerStatePoweredOn)
    {
        NSLog(@"蓝牙设备开着");
        flag = YES;
    }
    else
    {
        NSLog(@"蓝牙设备关着");
        flag = NO;
    }
}

- (BOOL)isOpen {
    if (flag) {
        return YES;
    }
    return NO;
}

@end










